package com.yan.listener;

import com.rabbitmq.client.Channel;
import org.springframework.amqp.core.Message;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.stereotype.Component;
/**
 * TODO
 *
 * @Author: 汪焰
 * @Date: 2021/7/8 22:39
 */
@Component
public class MyMeetingListener {

    @RabbitListener(queues = "queue.yan.delayed")
    public void onMessage(Message message, Channel channel) throws Exception {
        System.out.println("------------------------------");
        String msg = new String(message.getBody(), message.getMessageProperties().getContentEncoding());
        System.out.println("-------------" + msg);
        System.out.println("------------------------------");

        //消息确认
        channel.basicAck(message.getMessageProperties().getDeliveryTag(), false);
    }

}
